package com.rgh.pecunia.domain;

import java.util.Date;

import javax.persistence.Id;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.googlecode.objectify.annotation.Cached;

@Cached
@XmlRootElement
@SuppressWarnings("unchecked")
public class Account implements BusinessEntity {

    private static final long serialVersionUID = 1L;

    /* Id */
    @Id Long id;
    
    /* Name */
    String name;
    
    /* Created at */
    Date creation;
    
    /* Updated at */
    Date updated;
    
    /* Current balance */
    Double balance;
    
    // Alphanumeric key
    String key;

    public Account() {
        this.creation = new Date();
        this.updated = new Date();
        this.balance = new Double(0);
    }

    public Account(String name, Date creation, Date updated, 
            Double balance, String key) {
        this.name = name;
        this.creation = creation;
        this.updated = updated;
        this.balance = balance;
        this.key = key;
    }

    @XmlElement
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @XmlElement
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlElement
    public Date getCreation() {
        return creation;
    }

    public void setCreation(Date creation) {
        this.creation = creation;
    }

    @XmlElement
    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    @XmlElement
    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }
    
    @XmlElement
    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
}
